package backend.majiong.yaku.yaku;

import java.util.HashSet;
import java.util.Set;

import backend.MainGame;
import backend.majiong.Pai;
import backend.majiong.Player;
import backend.majiong.yaku.AbstractYaku;
import backend.majiong.yaku.HandCombo;


public class Ikkituukan extends AbstractYaku {

    @Override
    public boolean checkYaku(Player player, HandCombo combo, MainGame mainGame) {
        Set<Integer> wan = new HashSet<Integer>();
        Set<Integer> suo = new HashSet<Integer>();
        Set<Integer> pin = new HashSet<Integer>();
        for(Pai pai:combo.getSunZi()){
            if(Pai.TYPE_PIN.equals(pai.getType())){
                pin.add(pai.getNum());
            }
            if(Pai.TYPE_SOU.equals(pai.getType())){
                suo.add(pai.getNum());
            }
            if(Pai.TYPE_WAN.equals(pai.getType())){
                wan.add(pai.getNum());
            }
        }
        if(wan.contains(1) && wan.contains(4) && wan.contains(7)) {
            return true;
        }
        if(suo.contains(1) && suo.contains(4) && suo.contains(7)) {
            return true;
        }
        if(pin.contains(1) && pin.contains(4) && pin.contains(7)) {
            return true;
        }
        return false;
    }

    @Override
    public String getYakuName() {
        return "一气通贯";
    }

    @Override
    public Integer getYakuNum(boolean isMenQing) {
        if(isMenQing) {
            return 2;
        }
        return 1;
    }


}
